package com.yuoj.yuojbackendquestionservice.controller.inner;

import com.yuoj.backendcommon.entity.Question;
import com.yuoj.backendcommon.entity.QuestionSubmit;
import com.yuoj.yuojbackendquestionservice.service.QuestionService;
import com.yuoj.yuojbackendquestionservice.service.QuestionSubmitService;
import com.yuoj.yuojbackendserviceclient.service.QuestionFeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 刘渠好
 * @since 2025-04-12 19:28
 */
@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {

    @Resource
    private QuestionService questionService;

    @Resource
    private QuestionSubmitService questionSubmitService;

    @Override
    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getQuestionSubmitById(long questionSubmitId) {
        return questionSubmitService.getById (questionSubmitId);
    }

    @Override
    @PostMapping("/update/questionSubmit")
    public boolean updateQuestionSubmitById(QuestionSubmit questionSubmit) {
        return questionSubmitService.updateById(questionSubmit);
    }

    @Override
    public boolean updateQuestionById(Question question) {
        return questionService.updateById (question);
    }

    @Override
    @GetMapping("/question/get/id")
    public Question getQuestionById(long questionId) {
        return questionService.getById(questionId);
    }
}
